//Page Object
import { request } from "../../request/index.js"

Page({
  data: {
    swiperList: [],
    cateList:[],
    floorList:[]
  },
  //options(Object)
  onLoad: function (options) {
    // wx.request({
    //   url: 'https://api-hmugo-web.itheima.net/api/public/v1/home/swiperdata',
    //   methods:"get",
    //   success: (result) => {
    //     this.setData({
    //       swiperList:result.data.message
    //     })
    //   }
    // });
    this.getSwiperList();
    this.getCateList();
    this.getfloorList();
  },
  getSwiperList(){
    request({
      url: '/home/swiperdata',
    }).then(result => {
      this.setData({
        swiperList: result
      })
    },
    err=>{console.log("Error:",err);}
    )
    .catch(err=>{
      console.log("Error:",err);
    })
  },
  getCateList(){
    request({
      url: '/home/catitems',
    }).then(result => {
      this.setData({
        cateList: result
      })
    },
    err=>{console.log("Error:",err);}
    )
    .catch(err=>{
      console.log("Error:",err);
    })
  },
  getfloorList(){
    request({
      url: '/home/floordata',
    }).then(result => {
      this.setData({
        floorList: result
      })
    },
    err=>{console.log("Error:",err);}
    )
    .catch(err=>{
      console.log("Error:",err);
    })
  },
});
